package cn.sc.allinpay.allfavour.business.saledetail;

import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import butterknife.BindView;
import butterknife.OnClick;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.base.activity.BaseActivity;
import cn.sc.allinpay.allfavour.business.common.popwindow.AllinPayPopWindow;


/**
 * activity 售券详情
 * author：pany
 * on 2017/12/1 11:14
 */
public class SaleDetailActivity extends BaseActivity<SaleDetailContract.View, SaleDetailContract.Presenter>
        implements SaleDetailContract.View,AllinPayPopWindow.OnPayListener {

    @BindView(R.id.tvName)
    AppCompatTextView tvName;//券名
    @BindView(R.id.tvType)
    AppCompatTextView tvType;//类型
    @BindView(R.id.tvPriceAmt)
    AppCompatTextView tvPriceAmt;//面额
    @BindView(R.id.tvInventory)
    AppCompatTextView tvInventory;//库存
    @BindView(R.id.tvSalePrice)
    AppCompatTextView tvSalePrice;//售价
    @BindView(R.id.tvValidDate)
    AppCompatTextView tvValidDate;//有效期
    @BindView(R.id.tvExplain)
    AppCompatTextView tvExplain;//说明
    @BindView(R.id.tvNumTitle)
    AppCompatTextView tvNumTitle;//数量名称
    @BindView(R.id.tvNumer)
    AppCompatTextView tvNumer;//数量
    @BindView(R.id.tvPaidAmt)
    AppCompatTextView tvPaidAmt;//待支付金额

    private AllinPayPopWindow payPopWindow;

    @Override
    protected int layoutId() {
        return R.layout.activity_sale_detail;
    }

    @Override
    protected void layoutTitle(View top, AppCompatTextView left, AppCompatTextView title, AppCompatTextView right) {
        title.setText("售券");
    }

    @Override
    protected SaleDetailContract.Presenter bindPresenter() {
        return new SaleDetailPresenter();
    }

    @Override
    protected void layoutContent(Bundle savedInstanceState) {
        payPopWindow = new AllinPayPopWindow(this);
        payPopWindow.setOnPayListener(this);
    }

    @Override
    public void showName(String data) {
        tvName.setText(data);
    }

    @Override
    public void showType(String data) {
        tvType.setText(data);
    }

    @Override
    public void showPriceAmt(String data) {
        tvPriceAmt.setText(data);
    }

    @Override
    public void showInventory(String data) {
        tvInventory.setText(data);
    }

    @Override
    public void showSalePrice(String data) {
        tvSalePrice.setText(data);
    }

    @Override
    public void showValidDate(String data) {
        tvValidDate.setText(data);
    }

    @Override
    public void showExplain(String data) {
        tvExplain.setText(data);
    }

    @Override
    public void showNumTitle(String data) {
        tvNumTitle.setText(data);
    }

    @Override
    public void showNumber(String data) {
        tvNumer.setText(data);
    }

    @Override
    public void showPaidAmt(String data) {
        tvPaidAmt.setText(data);
    }

    @OnClick({R.id.btnReduce, R.id.btnAddit, R.id.btnPay})
    public void btnClick(View view) {
        switch (view.getId()) {
            case R.id.btnReduce:
                presenter.reduceNumber();
                break;
            case R.id.btnAddit:
                presenter.additNumber();
                break;
            case R.id.btnPay:
                payPopWindow.show(view);
                break;
        }

    }

    @Override
    public void onCardPay() {
        presenter.callSale();
    }

    @Override
    public void onScanPay() {
        presenter.callScan();
    }
}
